#pragma once
#include <boost/shared_ptr.hpp>

#include "OS.h"


class GlyphMetrics {
public:
	
	int ascent;

	int descent;

	int width;

	GlyphMetrics():ascent(0), descent(0), width(0){

	}

	GlyphMetrics(int ascent, int descent, int width) {
		assert(! (ascent < 0 || descent < 0 || width < 0) );

		this->ascent = ascent;
		this->descent = descent;
		this->width = width;
	};
};

class _Font{
public:
	INT32 font;
public:
	_Font(INT32 newFont = 0):font(newFont){

	};
	virtual ~_Font(){
		if(font){
			OS::DelFont(font);
		}
	}

};

class Font  {
public:
	Font() {
	}
	Font(INT32 font){
		_font.reset(new _Font(font));
	}
	virtual ~Font(){

	}
public:
	INT32 GetFont(){
		return _font->font;
	}
	void SetFont(INT32 newFont){
		_font.reset(new _Font(newFont));
	}
private:
	boost::shared_ptr<_Font> _font;
//TODO free the font
};

class Size: public SIZE {
public:
	Size(int _cx = 0, int _cy = 0);
};

class Point: public POINT {
public:
	explicit Point(int _x = 0, int _y = 0);
	Point(const POINT& pt);
};

class Rect: public RECT {
public:
	explicit Rect(int _left = 0, int _top = 0, int _right = 0, int _bottom = 0);
	Rect(const RECT& r);
	Rect(const RECT* r);
	int Width() const;
	int Height() const;
	bool Empty() const;
	Rect& Inflate(int dx, int dy);
	Rect& Move(int deltaX, int deltaY);
	Rect& Offset(int deltaX, int deltaY);
	bool operator==(const Rect& other) const;

	bool Contains(const Point& pt) const;
	bool Contains(const Rect& rc)  const;
};

class Color {
public:
	Color(COLORREF color = 0);
	Color(UINT red, UINT green, UINT blue);
	Color& Set(COLORREF color);
	Color& Set(UINT r, UINT g, UINT b);
	UINT GetRed() const;
	UINT GetGreen() const;
	UINT GetBlue() const;
	COLORREF AsColorRef() const;
	Color& operator=(COLORREF color);
	operator COLORREF();
	static unsigned int ValueOfHex(char ch) ;
	Color& Set(const char* val);
	static unsigned int ValueOfHex(const wchar_t ch);
	Color& Set(const wchar_t* val);
private:
	COLORREF color_;
};

class Dc {
public:
	Dc(HDC dc);
	virtual ~Dc();
public:
	HDC GetDC() const;
	operator HDC();
public:
	BOOL Rectangle(int left, int top, int right, int bottom) const;
	BOOL Rectangle(const Rect& rect) const;
	BOOL RoundRect(int left, int top, int right, int bottom, int width, int height)const ;
	BOOL RoundRect(const Rect& rect, int width, int height)const ;
protected:
	HDC dc_;
};




class Graphic {
public:
	Graphic(void);
	virtual ~Graphic(void);
};
